package cn.youwan.market.Fragment;

import java.util.ArrayList;
import java.util.List;

import cn.youwan.market.ManageActivity;
import cn.youwan.market.R;
import cn.youwan.market.adapter.TuijianAdapter;
import cn.youwan.market.entity.AppListBean;
import cn.youwan.market.entity.PromotionListbean.Appbean;
import cn.youwan.market.message.YouwanMessage;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

public class SelectFragment extends Fragment{
	private ListView lv;
	protected AppListBean bean;
	protected TuijianAdapter adapter;
	protected int page=1;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v=inflater.inflate(R.layout.select, null);
		initView(v);
		getMoreGameRank();
		return v;
	}

	private void initView(View v) {
		lv=(ListView)v.findViewById(R.id.test_lv);
		
		
	}
	
	
	public void getMoreGameRank() {
		new AsyncTask<Void, Void, Void>() {

			protected void onPreExecute() {
			};

			@Override
			protected Void doInBackground(Void... params) {
				YouwanMessage message = new YouwanMessage(getActivity());
				bean = message.getAppsList("http://gd.7pingmi.com.cn/game/server/?m=gameInfo",page);
				return null;
			}

			@Override
			protected void onPostExecute(Void result) {
				super.onPostExecute(result);
				List<Appbean> apps=bean.getBeans();
				Log.i("load APPS", apps.toString());
				adapter=new TuijianAdapter(getActivity(), apps, lv);
				lv.setAdapter(adapter);
			}
		}.execute();
	}
	
	
}
